Skip to content

fix(assets): fetch and draw depot renders stored under sub-directories - #2461

Open
AprilNEA wants to merge 1 commit into
masterfrom
fix/asset-sub-path-resources
Open

AprilNEA wants to merge 1 commit into
masterfrom
fix/asset-sub-path-resources

Conversation

@AprilNEA

@AprilNEA AprilNEA commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Summary

The g502x_plus depot names every render by its path inside the depot (images/device/<uuid>), and so do the other 44 G HUB depots in the asset catalog. Two defects kept a G502 X PLUS colour variant on the black base render with no side view:

  • Download and read. The asset fetch and the resolver joined every remote file name with safe_component_path, which accepts only a single path component. Each sub-path file failed with "asset file name must be a single safe path component", so only the root files (front.png, manifest.json, metadata.json) were cached. The resolver also refused the same names, so they could not have been drawn even if they were cached.
  • Side-view lookup. resolve_side_view looked up the variant's device_side using only the registry model ids (c095, 4099). The sync, and drawable_variant since fix(gui): draw the base model for a colour variant whose renders are not images #2379, use candidate_manifest_bases, which adds the depot name. G HUB manifests key variants on the depot name (g502x_plus_ext1), so the lookup missed and fell back to a side.png that this depot does not ship. The same miss gave the drawable purple G502 LIGHTSPEED the black side.png next to its purple front.

Both mirrors serve the sub-path files: Pages and the jsDelivr shard @logi-assets/pointing-gaming-x return the same bytes. So the fix is client-side only.

Changes

  • openlogi-assets
    • New http::safe_relative_path. It splits a depot-relative path on / and runs every segment through safe_component_path, so empty, ., .., rooted, prefixed and backslash segments are still rejected and the joined path cannot leave the depot. Rejections report the new AssetError::UnsafeRelativePath.
    • fetch_entry_if_stale joins file.name with it. write_replace creates the destination's parent directory.
    • The ManifestResource::src docs now say that src can be a sub-path.
  • openlogi-desktop
    • Every file-name join in the resolver now uses safe_relative_path. Depot names still go through safe_component_path.
    • resolve_side_view now resolves the variant's side render through find_variant_in_manifest(…, side_image_for). That is the lookup the sync downloads by, so the two can no longer disagree.

This branch is rebased on #2463, which reads WebP render sizes (#2460). The G502 X PLUS ext2 renders are WebP under images/device/, so they need both changes.

Out of scope, filed separately: the macOS bundle (openlogi assets sync) still selects optional files by flat name pattern, so it never includes sub-path renders (#2459).

Testing

New regression tests. All of them fail on master and pass with this change:

  • openlogi-assets http::tests::fetch_entry_writes_a_sub_path_file_into_its_depot_sub_directory: a local HTTP server; the fetch requests the sub-path, lands the file in images/device/, and the second call is a cache hit.
  • openlogi-desktop services::assets::sync::tests::g502x_plus_sync_fetches_variant_renders_under_images_device: sync_depot for the white variant (ext 1) fetches both images/device/ renders.
  • openlogi-desktop services::assets::tests::a_colour_variant_draws_its_renders_from_a_depot_sub_directory: the white G502 X PLUS resolves its own front and side renders.
  • openlogi-desktop services::assets::tests::a_webp_colour_variant_draws_its_renders_from_a_depot_sub_directory: the ext2 G502 X PLUS resolves its WebP front and side renders from images/device/, each at its own size. This is the catalog layout end to end, on top of fix(gui): read webp render sizes for the side and main views #2463.
  • a_drawable_colour_variant_keeps_its_renders_and_metadata gains a side-view assertion: the purple G502 LIGHTSPEED now gets its own side render.

New guards: safe_relative_path_accepts_names_and_depot_sub_paths, safe_relative_path_rejects_any_unsafe_segment, and a_manifest_sub_path_cannot_reach_outside_its_depot (images/../../side.png is not read).

Local gate, full tier after the rebase onto b50c24e99 (Linux; no Cargo.toml or lockfile change):

export RUSTFLAGS="-D warnings"
cargo fmt --all -- --check
typos --config .config/typos.toml .
ast-grep scan && ast-grep scan .github
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace
RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items \
  --exclude openlogi-ui --exclude openlogi-desktop --exclude openlogi-overlay --exclude openlogi-agent

Not run locally (left to CI): macOS and Windows clippy and tests, MSRV, and cargo-deny. cargo-deny is not affected because no dependency changed.

Not runtime-tested on hardware. To check: connect a white G502 X PLUS and start with an empty asset cache. assets/g502x_plus/images/device/ should then hold e0e9dacc-… and 22c9ac7a-…, and the Buttons tab should show the white render with the side view beside it. An ext2 unit should show its own WebP renders the same way.

Fixes #2457

@AprilNEA AprilNEA added type: bug Something is broken or behaves incorrectly area: gui Graphical user interface area: assets Icons, images, and bundled assets labels Nov 8, 2026
@greptile-apps

greptile-apps Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The reviewed changes appear safe to merge.

Summary

The PR lets asset downloads and reads use checked depot-relative paths. Side-render lookup now follows the same manifest candidates as sync.

  • Depot files can now be fetched and found inside safe subfolders.
  • Side views now follow the manifest entry for the selected variant.

Reviews (3) · Last reviewed commit: "fix(assets): fetch and draw depot render..." · Reviewed by Greptile

G HUB depots name their renders by a path inside the depot
(`images/device/<uuid>`). The fetch and the resolver joined every file
name with `safe_component_path`, which accepts a single component only,
so a G502 X PLUS colour variant never downloaded its front and side
renders and could not have drawn them.

Join depot files with the new `safe_relative_path`, which checks every
`/`-separated segment with the same rules, and create the parent
directory on write.

The side view also looked its variant up by registry model id only,
while the sync downloads by the manifest bases that include the depot
name, which G HUB manifests key on. Resolve it through
`find_variant_in_manifest` like the other variant renders.

Fixes #2457
@21omen

21omen commented Nov 8, 2026

Copy link
Copy Markdown

Tested on hardware: white G502 X PLUS (14099, ext1) over its Lightspeed receiver, Linux, this branch merged with #2456, empty asset cache.

  • Both renders download into g502x_plus/images/device/: e0e9dacc-… (2,403,553 bytes) and 22c9ac7a-… (1,726,616 bytes); no variant fetch failed any more.
  • The Buttons tab shows the white front render with the side view beside it.
  • With feat(core): add the G502 X PLUS gaming layout #2456's layout, all extra buttons get their hotspots, including sniper (G6), back and forward on the side render.

No ext2 unit here, so the WebP path is untested.

@iahoeu

iahoeu commented Nov 18, 2026

Copy link
Copy Markdown

Another depot this fixes: g502_hero (wired G502 HERO, 046d:c08b). Its registry model ids are c08b / aae6, the manifest keys device_side under g502_hero, and there is no top-level side.png, so the side view never resolved. With the same lookup change applied on top of master 9ca7ef0 plus #2293, the side view and the back / forward / G6 hotspots appear on Windows 11. Details in #2293.

@davidbudnick davidbudnick added the platform: all Cross-platform issue label Nov 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: assets Icons, images, and bundled assets area: gui Graphical user interface needs: decision Needs a maintainer/product decision platform: all Cross-platform issue type: bug Something is broken or behaves incorrectly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: g502x_plus variant and side renders never download (manifest uses images/device/ sub-paths)

4 participants